package com.clsz.controller;

import com.clsz.service.SMSService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/user")
public class SMSController {
    @Autowired
    private SMSService smsService;

    /***
     * 发送短信
     * @param phone
     * @return
     * @throws Exception
     */
    @GetMapping("/sms/")
    public Object getSMSValidate(String phone) throws Exception {
        Map<String, Object> res = new HashMap<>();
        System.out.println(phone);
        boolean b = smsService.sendSMSValidate(phone);
        if (b) {
            res.put("code", "200");
            res.put("message", "OK");
        } else {
            res.put("code", "500");
            res.put("message", "FAILD");
        }
        return res;
    }
}
